import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * @author DJJ_F
 * @version 1.0
 * @date 2024/11/28
 * @description
 */
public class BeanScope {
    @Test
    public void BeanScopeTest() {
        ApplicationContext applicationContext = new ClassPathXmlApplicationContext("bean-scope.xml");
        Object person = applicationContext.getBean("person");
        System.out.println(person);
        person = applicationContext.getBean("person");
        System.out.println(person);
        // 新建一个线程
        new Thread(new Runnable() {
            @Override
            public void run() {
                Object person = applicationContext.getBean("person");
                System.out.println(person);
                person = applicationContext.getBean("person");
                System.out.println(person);
            }
        }).start();
    }
}
